package com.cloud.feign;

import feign.Request;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
import org.springframework.context.annotation.Bean;
import org.springframework.core.env.ConfigurableEnvironment;

/**
 * Created by chenye on 2018/3/17.
 */
@SpringBootApplication
@EnableDiscoveryClient //发现所有eureka上注册的服务
@EnableFeignClients//开启feign功能
//@EnableHystrixDashboard//开启hystrix监控
public class ServiceFeignApplication {
    public static void main(String[] args){
        SpringApplication.run(ServiceFeignApplication.class,args);
    }


    @Bean
    Request.Options requestOptions(ConfigurableEnvironment env){
        int ribbonReadTimeout = env.getProperty("ribbon.ReadTimeout", int.class, 6000);
        int ribbonConnectionTimeout = env.getProperty("ribbon.ConnectTimeout", int.class, 3000);
        return new Request.Options(ribbonConnectionTimeout, ribbonReadTimeout);
    }
}
